<form action="{:sysuri()}" class="layui-form layui-card" id="translate_form" onsubmit="return false;">
    <div class="layui-card-body">

        {if !empty($account_show) }
        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:lang("公司")}:</label>
            <div class="layui-input-block">
                <select name="account_id" class="layui-select" required>
                    <option value="">请选择</option>
                    {if !empty($account_arr) }
                    {foreach $account_arr as $account_id => $account_name }
                    <option value="{$account_id|default=''}" >{$account_name|default=''}</option>
                    {/foreach}
                    {/if}
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:lang('原始语言')}</label>
            <input type="hidden" name="ids" value="{$goods_ids|default=''}">
            <div class="layui-input-block">
              <select name="from_lang" lay-verify="required" lay-search>
                <option value="">{:lang('请选择')}</option>
                {if !empty($langList) }
                {foreach $langList as $key => $item}
                <option value="{$item.code|default=''}">{$item.name|default=''}</option>
                {/foreach}
                {/if}
              </select>
            </div>
        </div> 

        <div class="layui-form-item">
            <label class="layui-form-label label-required-next">{:lang('翻译语言')}</label>
            <div class="layui-input-block">
              <select name="to_lang" lay-verify="required" lay-search>
                <option value="">{:lang('请选择')}</option>
                {if !empty($langList) }
                {foreach $langList as $key => $item}
                <option value="{$item.code|default=''}">{$item.name|default=''}</option>
                {/foreach}
                {/if}
              </select>
            </div>
        </div> 

        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('其他选项')}</label>
            <div class="layui-input-block">
                {if !empty($transfer_extra) }
                {foreach $transfer_extra as $key => $item}
                    <input type="checkbox" name="trans_ext[{$key|default=''}]" title="{$item|default=''}" value="{$item|default=''}">
                {/foreach}
                {/if}
            </div>
        </div>

        <div class="layui-input-block text-center">
            {if empty($account_show) }
            <input type="hidden" name="account_id" value="{$shop_account|default=0}">
            {/if}
          <button type="submit" class="layui-btn" lay-submit lay-filter="trans_btn">{:lang('翻译')}</button>
          <button class="layui-btn layui-btn-danger" type='button' data-close>{:lang('取消')}</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form'], function(){
        let form = layui.form;
        // 提交
        form.on('submit(trans_btn)', function(data){
            let field = data.field;
            if(!isNotEmpty(field.from_lang)){
                $.msg.error('{:lang("请选择原始语言")}')
                return false;
            }
            if(!isNotEmpty(field.to_lang)){
                $.msg.error('{:lang("请选择翻译语言")}')
                return false;
            }
            $.ajax({
                url: "{:sysuri()}",
                type: "post",
                data: field,
                dataType: "json",
                success: function (res) {
                    if (res.code === 1) {
                        $.msg.success(res.info, 3, function () {
                            $.msg.closeThisModal('#translate_form')
                        });
                    }else{
                        $.msg.error(res.info);
                    }
                }
            });
            return false;
        })
    })
</script>